﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DbfTools;
using System.Data;

namespace DbfViewer.Models
{
	public class FileBasedDbfFile : IDbfFile
	{
		private string fileName;
		public string FileName
		{
			get { return fileName; }
			set { fileName = value; }
		}

		public FileBasedDbfFile(string fileName)
		{
			this.fileName = fileName;
			table = DBFile.Load(fileName);
		}


		#region IDbfFile Members

		public void Save()
		{
			DBFile.Save(fileName, table);
		}

		private DataTable table;
		public DataTable Table
		{
			get { return table; }
		}

		public void AddField(DataColumn field)
		{
			if (field != null)
			{
				Table.Columns.Add(field);
			}
		}

		#endregion
	}
}
